<div>
  <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
    <el-breadcrumb-item :to="{ path: '/users' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    <el-breadcrumb-item>用户列表</el-breadcrumb-item>
  </el-breadcrumb>

  <el-row type="flex" :gutter="20">
    <el-col :span="8">
      <el-input
        placeholder="请输入内容"
        v-model="searchText"
        class="input-with-select"
      >
        <el-button
          slot="append"
          icon="el-icon-search"
          @click="search"
        ></el-button>
      </el-input>
    </el-col>
    <el-col :span="4">
      <el-button @click="dialogFormVisible=true">添加用户</el-button></el-col
    >
  </el-row>

  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="username" label="姓名" width="180">
    </el-table-column>
    <el-table-column prop="email" label="邮箱" width="180"> </el-table-column>
    <el-table-column prop="mobile" label="电话"> </el-table-column>
    <el-table-column label="用户状态">
      <template slot-scope="scope">
        <el-switch
          v-model="scope.row.mg_state"
          @change="updateStatus(scope.row)"
        >
        </el-switch>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          icon="el-icon-edit"
          size="mini"
          plain
          type="primary"
          @click="updateFormVisibleFun(scope.row)"
        ></el-button>
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          @click="removeUser(scope.row)"
        ></el-button>
        <el-button type="success" plain size="mini">分配角色</el-button>
      </template>
    </el-table-column>
  </el-table>

  <el-pagination
    background
    layout="prev, pager, next"
    :total="total"
    :page-size="pagesize"
    @current-change="currentChange"
    :current-page="curPage"
  >
  </el-pagination>

  <el-dialog title="添加用户" :visible.sync="dialogFormVisible">
    <el-form :model="form" :rules="rules" ref="addForm">
      <el-form-item label="用户名" label-width="80px" prop="username">
        <el-input v-model="form.username" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="密码" label-width="80px" prop="password">
        <el-input v-model="form.password" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" label-width="80px">
        <el-input v-model="form.email" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="手机" label-width="80px">
        <el-input v-model="form.mobile" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="addUser">确 定</el-button>
    </div>
  </el-dialog>

  <el-dialog title="修改用户" :visible.sync="updateFormVisible">
    <el-form :model="editUserForm">
      <el-form-item label="用户名" label-width="80px">
        <el-button type="info" plain disabled>
          {{ editUserForm.username }}
        </el-button>
      </el-form-item>
      <el-form-item label="邮箱" label-width="80px">
        <el-input v-model="editUserForm.email" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="手机" label-width="80px">
        <el-input v-model="editUserForm.mobile" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="updateFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="updateUser()">确 定</el-button>
    </div>
  </el-dialog>
</div>
